﻿@{
    ViewBag.Title = "菜单管理";
    ViewBag.FirstPage = "系统管理";
    ViewBag.LastPage = "菜单列表";
    Layout = "~/Views/MasterPage.cshtml";
}

<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<style>
    .am-btn-group am-btn-group-xs a {
        color: blue;
    }

        .am-btn-group am-btn-group-xs a :hover {
            color: orange;
            cursor: pointer;
        }
</style>
<div class="am-g">
    <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
            <div class="am-btn-toolbar am-fl">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default" id="btnAdd"><span class="am-icon-plus"></span>新增</button>

                </div>

                <div class="am-form-group am-margin-left am-fl">
                </div>
            </div>
        </div>
    </div>
    <div class="am-u-md-3 am-cf">
        <div class="am-fr">
            <div class="am-input-group am-input-group-sm">

                <span class="am-input-group-btn"></span>
            </div>
        </div>
    </div>
</div>
<div class="am-g">
    <div class="am-u-sm-12">
        <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>

                        <th class="table-title">菜单编号</th>
                        <th class="table-type">菜单</th>
                        <th class="table-date">父级菜单</th>
                        <th class="table-author">是否是父级菜单</th>
                        <th class="table-date">操作时间</th>
                        <th class="table-set">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @{
                     
                        var list = BLL.MenusManager.QueryList().OrderBy(a => a.OrderIndex).ToList();
                        foreach (var item in list)
                        {
                            
                        <tr>

                            <td>@item.Id</td>
                            <td>@item.Name</td>
                            <td>
                                @{
                            var parentName = string.Empty;
                            if (!item.IsParent)
                            {
                                parentName = BLL.MenusManager.GetEntity(item.ParentId) == null ? "" : BLL.MenusManager.GetEntity(item.ParentId).Name;
                                    @parentName
                            }
                            else
                            {
                                    @parentName
                            }
                            
                                }

                            </td>
                            <td>
                                @{
                            if (item.IsParent)
                            { 
                                    @:是
                            }
                            else
                            {
                                    @:否
                            }
                                }

                            </td>
                            <td>@item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a>编辑</a>

                                    </div>
                                </div>
                            </td>
                        </tr> 
                        }
                           
                    }


                </tbody>
            </table>
            <div class="am-cf">
                <div class="am-fr">
                </div>
            </div>
            <hr>
        </form>
    </div>

</div>
<script src="/Source/layui/layui.js"></script>
<script src="/Source/layui/layui.all.js"></script>
<link href="/Source/layui/css/layui.css" rel="stylesheet" />
<script>
    $(function () {
        $("#btnAdd").click(function () {
            layer.open({
                type: 2,
                title: "新增菜单",
                area: ['500px', '450px'],
                content: "/Menus/Insert"
            });
        });

    })
</script>
